Ext.define("wmf.view.product.edit", {
    extend: "wmf.lib.FormPanel",
    alias: "widget.productEdit",
	anchor: '100% 100%',
    border: false,
    autoScroll: true,
    fieldDefaults: {
    	labelAlign: 'right',
        labelWidth: 60
    },
    items: [{
        xtype: "textfield",
        name: "productName", 
        allowBlank: false,
        vtype: 'propertyType',
        fieldLabel: "产品名称"
    },{
    	xtype: "textfield",
        name: "id", 
        allowBlank: false,
        editable: false,
        fieldLabel: "产品ID"
    },{
    	xtype: 'combo',
 		emptyText:  '请选择...',
 		hiddenName: 'ecId',
 		autoSelect: true,
 		allowBlank: false,
 		displayField: 'name',
 		queryMode: 'remote',
 		valueField: 'ecId',
 		triggerAction: 'all',
 		editable: false,
 		store: 'access.ecId',
        name: "ecId", 
        fieldLabel: "关联企业"
    },{
    	xtype: 'combo',
 		emptyText:  '请选择...',
 		hiddenName: 'channelType',
 		autoSelect: true,
 		displayField: 'name',
 		queryMode: 'local',
 		valueField: 'channelType',
 		allowBlank: false,
 		triggerAction: 'all',
 		editable: false,
 		store: 'channel.channelType',
        name: "businessType", 
        fieldLabel: "业务类型"
    },{
    	xtype: 'combo',
 		emptyText:  '请选择...',
 		hiddenName: 'serviceType',
 		autoSelect: true,
 		displayField: 'name',
 		allowBlank: false,
 		queryMode: 'local',
 		valueField: 'serviceType',
 		triggerAction: 'all',
 		editable: false,
 		store: 'product.serviceType',
        name: "serviceType", 
        fieldLabel: "服务种类"
    },{
    	xtype: 'fieldcontainer',
        combineErrors: true,
        msgTarget : 'side',
        layout: 'hbox',
        items: [{
        	xtype: 'combo',
     		emptyText:  '请选择...',
     		hiddenName: 'id',
     		autoSelect: true,
     		displayField: 'cmccChannelId',
     		queryMode: 'remote',
     		valueField: 'id',
     		triggerAction: 'all',
     		editable: false,
     		store: 'product.channel1',
            name: "cmccChannelId", 
            minChars: 0,
    		forceSelection : true,
    		selectOnFocus : true,
            listeners : {
    			'beforeQuery': function(e){
    				var combo = e.combo;
    				var panel = combo.up('panel');
    				var bsType = panel.query('combo[name=businessType]')[0].getValue();
    				if(!bsType){
    					Ext.Msg.alert('提示', '请先选择选择业务类型');
    					return false;
    				}
    				delete e.combo.lastQuery;
    				combo.store.clearFilter();
    				combo.store.filter({
		        		property     : 'carrier',
		        		value        : '1',
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});  
		    	    combo.store.filter({
		        		property     : 'status',
		        		value        : '1',
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});
		    	    combo.store.filter({
		        		//property     : combo.displayField,
		        		property     : 'channelType',
		        		value        : bsType,
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});
		    	    combo.onLoad();
    			}
    		},
            flex: 3,
        	fieldLabel: "移动通道"
        },{
        	xtype: "textfield",
            name: "cmccChannelSrcid", 
            labelWidth: 90,
            flex: 3,
            vtype: 'channelId',
            fieldLabel: "长号码扩展位"
        }]
    },{
        xtype: "textfield",
        name: "cmccChannelExtParams", 
        vtype: 'propertyName',
        fieldLabel: "附加参数"
    },{
    	xtype: 'fieldcontainer',
        combineErrors: true,
        msgTarget : 'side',
        layout: 'hbox',
        items: [{
        	xtype: 'combo',
     		emptyText:  '请选择...',
     		hiddenName: 'id',
     		autoSelect: true,
     		displayField: 'unicomChannelId',
     		queryMode: 'remote',
     		valueField: 'id',
     		triggerAction: 'all',
     		editable: false,
     		store: 'product.channel2',
            name: "unicomChannelId", 
            flex: 3,
            minChars: 0,
    		forceSelection : true,
    		selectOnFocus : true,
            listeners : {
    			'beforeQuery': function(e){
    				var combo = e.combo;
    				var panel = combo.up('panel');
    				var bsType = panel.query('combo[name=businessType]')[0].getValue();
    				if(!bsType){
    					Ext.Msg.alert('提示', '请先选择选择业务类型');
    					return false;
    				}
    				delete e.combo.lastQuery;
    				combo.store.clearFilter();
		    	    combo.store.filter({
		        		//property     : combo.displayField,
		        		property     : 'carrier',
		        		value        : '2',
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});  
		    	    combo.store.filter({
		        		//property     : combo.displayField,
		        		property     : 'status',
		        		value        : '1',
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});
		    	    combo.store.filter({
		        		//property     : combo.displayField,
		        		property     : 'channelType',
		        		value        : bsType,
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});
		    	    combo.onLoad();
    			}
    		},
            fieldLabel: "联通通道"
        },{
        	xtype: "textfield",
            name: "unicomChannelSrcid", 
            labelWidth: 90,
            vtype: 'channelId',
            flex: 3,
            fieldLabel: "长号码扩展位"
        }]
    },{
        xtype: "textfield",
        name: "unicomChannelExtParams", 
        vtype: 'propertyName',
        fieldLabel: "附加参数"
    },{
    	xtype: 'fieldcontainer',
        combineErrors: true,
        msgTarget : 'side',
        layout: 'hbox',
        items: [{
        	xtype: 'combo',
     		emptyText:  '请选择...',
     		hiddenName: 'id',
     		autoSelect: true,
     		displayField: 'telcomChannelId',
     		queryMode: 'remote',
     		valueField: 'id',
     		triggerAction: 'all',
     		editable: false,
     		store: 'product.channel',
            flex: 3,
            minChars: 0,
    		forceSelection : true,
    		selectOnFocus : true,
            listeners : {
    			'beforeQuery': function(e){
    				var combo = e.combo;
    				var panel = combo.up('panel');
    				var bsType = panel.query('combo[name=businessType]')[0].getValue();
    				if(!bsType){
    					Ext.Msg.alert('提示', '请先选择选择业务类型');
    					return false;
    				}
    				delete e.combo.lastQuery;
    				combo.store.clearFilter();
		    	    combo.store.filter({
		        		//property     : combo.displayField,
		        		property     : 'carrier',
		        		value        : '3',
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});  
		    	    combo.store.filter({
		        		//property     : combo.displayField,
		        		property     : 'status',
		        		value        : '1',
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});
		    	    combo.store.filter({
		        		//property     : combo.displayField,
		        		property     : 'channelType',
		        		value        : bsType,
		        		anyMatch     : true, //optional, defaults to true
		        		caseSensitive: false  //optional, defaults to true
		        	});
		    	    combo.onLoad();
    			}
    		},
            name: "telcomChannelId", 
            fieldLabel: "电信通道"
        },{
        	xtype: "textfield",
            name: "telcomChannelSrcid", 
            labelWidth: 90,
            vtype: 'channelId',
            flex: 3,
            fieldLabel: "长号码扩展位"
        }]
    },{
        xtype: "textfield",
        name: "telcomChannelExtParams", 
        vtype: 'propertyName',
        fieldLabel: "附加参数"
    },{
    	xtype: 'combo',
 		emptyText:  '请选择...',
 		hiddenName: 'priority',
 		autoSelect: true,
 		displayField: 'name',
 		queryMode: 'local',
 		valueField: 'priority',
 		triggerAction: 'all',
 		allowBlank: false,
 		editable: false,
 		store: 'product.priority',
        name: "priority", 
        fieldLabel: "优先级"
    },{
    	xtype: 'combo',
 		emptyText:  '请选择...',
 		hiddenName: 'needAudit',
 		autoSelect: true,
 		displayField: 'name',
 		queryMode: 'local',
 		valueField: 'needAudit',
 		triggerAction: 'all',
 		editable: false,
 		allowBlank: false,
 		store: 'product.needAudit',
        name: "needAudit", 
        fieldLabel: "是否审核"
    }],
    
	dockedItems: [{
		xtype: 'toolbar',
		dock: 'bottom',
		layout: {
				type: 'hbox',
				alian: 'center',
				flex: 1
		},
		
		defaults: {
			xtype: 'button'
		},
		items: [{
			xtype : 'tbfill'
		},{
			itemId: 'save',
			icon: 'resources/icons/pencil.png',
			formBind: true,
			text: translations.global.operation.edit
		},{
			itemId: 'reset',
			icon: 'resources/icons/icon_recover.png',
			text: translations.global.operation.reset
		},{
			itemId: 'cancel',
			icon : 'resources/icons/icon_revoke.png',
			text: translations.global.operation.cancel
		}]
	}]
});